import { defineStore } from 'pinia';
import pic from '/public/images/mz.jpg';

export const useUsersStore = defineStore('user', {
  state: () => ({
    user: {
      id: 'hdl_001',
      avatar: pic,
      nickname: '程序员小何',
      email: '13206920390@163.com',
      username: '程序员小何',
      sex: '男',
      age: '28',
      desc: '一个愿意学习的前端菜鸟',
      loginType: undefined,
      path: '',
      articleLikeSet: [],
      commentLikeSet: [],
      talkLikeSet: [],
    },
    userInfo: {},
  }),
  actions: {
    setUserInfo(data) {
      this.userInfo = data;
    },
  },
  persist: {
    enabled: true,
    strategies: [
      {
        key: 'user', // 存储在 localStorage 的键名
        storage: localStorage, // 使用 localStorage
        paths: ['userInfo'], // 需要持久化的 state 路径
      },
    ],
  },
});
